﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Data;
using System.Globalization;

namespace BadHabit.Factory.Converters {

    [ValueConversion(typeof(object), typeof(bool))]
    public class VelocityIsHigherConverter : IValueConverter {

        public static double MaxVelocity { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {

            double velocity = 0;

            if (value == null)
                return false;

            if (value is String)
                Double.TryParse(value.ToString(), out velocity);

            if(value is double)
                velocity = (double)value;



            return (velocity > MaxVelocity);

        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
            return new NotSupportedException();
        }

    }
}
